using System;
using System.Collections.Generic;
using System.Text;
using RebEngine.Interfaces;
using Microsoft.Xna.Framework;
using RebEngine.GameComponents;
using RebEngine.Managers;
using Microsoft.Xna.Framework.Graphics;
using System.Collections;

namespace RebEngine.SceneObject.SceneGraph
{
    public class SceneObjectNode : Node, IComparable
    {
        private RebSceneObject _sceneObject;
        public RebSceneObject SceneObject
        {
            get { return _sceneObject; }
            set { _sceneObject = value; }
        }

        public SceneObjectNode(RebSceneObject newObject, string name)
            :base(name)
        {
            _sceneObject = newObject;
        }

        public override void Update(GameTime gameTime)
        {
            if (SceneObject is IRebUpdateable)
                ((IRebUpdateable)SceneObject).Update(gameTime);
        }

        public override void LoadContent()
        {
            if (SceneObject is IRebLoadable)
                ((IRebLoadable)SceneObject).LoadContent();
        }

        public override void Draw(GameTime gameTime)
        {

            SceneObject.Draw(gameTime);
            if (Nodes.Count > 0)
            {
                if (CameraManager.ActiveCamera.Position.Z < 300)
                {
                    foreach (var node in Nodes)
                    {
                        node.Draw(gameTime);
                    }
                }
            }
            
        }


    }
}
